const bannerModel = require('./schema/bannerSchema')

module.exports.findBannerDao = async function () {
  const result = await bannerModel.find()
  return result
}

module.exports.updateBannerDao = async function (bannerArr) {
  await bannerModel.deleteMany({})
  // // 删除每个对象的id字段
  const sanitizedBanners = bannerArr.map(({ id, ...rest }) => rest);
  await bannerModel.create(sanitizedBanners)
  return bannerModel.find()
}
